﻿package mortal.game.view.guildNew.WareHourse
{
    import Message.Game.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import flash.events.*;
    import flash.utils.*;
    import mortal.common.global.*;
    import mortal.common.tools.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.mvc.core.*;

    public class GuildNewWareHCell2 extends GCellRenderer
    {
        protected var _line:ScaleBitmap;
        protected var _nameTxt:GTextFiled;
        protected var _posN:GTextFiled;
        protected var _levelN:GTextFiled;
        protected var _adon:GTextFiled;
        protected var _item:NumLevelBaseItem;
        protected var _agreeBtn:GButton;
        protected var _rejBtn:GButton;

        public function GuildNewWareHCell2()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._line = UIFactory.bg(0, 48, 320, 1, this, ImagesConst.SplitLine);
            this._nameTxt = UIFactory.gTextField("", 3, 2, 90, 20, this, GlobalStyle.textFormatPutong.setColor(16777215).center());
            this._posN = UIFactory.gTextField("", 1, 23, 100, 20, this, GlobalStyle.textFormatPutong.setColor(16777215).center());
            this._levelN = UIFactory.gTextField("", 41, 23, 50, 20, this, GlobalStyle.textFormatPutong.setColor(16777215).right());
            this._adon = UIFactory.gTextField("12-25 16:45", 108, 14, 82, 25, this, GlobalStyle.textFormatLv.center());
            this._item = UIFactory.getUICompoment(NumLevelBaseItem);
            this._item.setItemStyle(ItemStyleConst.Small, ImagesConst.PackItemBg, 2, 2);
            UIFactory.setObjAttri(this._item, 198, 4, -1, -1, this);
            this._agreeBtn = UIFactory.gButton("" + Language.getString(71628), 240, 10, 33, 29, this);
            this._rejBtn = UIFactory.gButton("" + Language.getString(71629), 276, 10, 33, 29, this);
            var _loc_1:Boolean = false;
            this._item.mouseEnabled = false;
            var _loc_1:* = _loc_1;
            this._item.isDropAble = _loc_1;
            this._item.isDragAble = _loc_1;
            this._agreeBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this._rejBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            this._levelN.visible = false;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._line = null;
            this._nameTxt = null;
            this._posN = null;
            this._levelN = null;
            this._adon = null;
            this._item = null;
            this._agreeBtn = null;
            this._rejBtn = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function onClickHandler(event:MouseEvent) : void
        {
            var _loc_4:Dictionary = null;
            var _loc_2:* = this.data as SGuildWarehouseApply;
            var _loc_3:Object = {};
            _loc_3.toPlayerId = _loc_2.playerId;
            _loc_3.uid = _loc_2.uid;
            if (_loc_3.uid == 0)
            {
                _loc_4 = new Dictionary();
                _loc_4[_loc_2.unit] = _loc_2.amount;
                _loc_3.applyMoney = _loc_4;
            }
            else
            {
                _loc_3.applyMoney = new Dictionary();
            }
            switch(event.currentTarget)
            {
                case this._agreeBtn:
                {
                    _loc_3.opr = true;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Guild_wareHouse_dealApplyList, _loc_3));
                    break;
                }
                case this._rejBtn:
                {
                    _loc_3.opr = false;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Guild_wareHouse_dealApplyList, _loc_3));
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        override public function get data() : Object
        {
            return super.data;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_2:SGuildWarehouseApply = null;
            var _loc_3:ItemData = null;
            super.data = param1;
            if (param1 is SGuildWarehouseApply)
            {
                _loc_2 = param1 as SGuildWarehouseApply;
                this._nameTxt.text = _loc_2.name;
                this._posN.text = GameDefConfig.instance.getGuildPositonName(_loc_2.position);
                this._adon.text = DateParser.parse(_loc_2.applyDt, "MM-dd hh:mm");
                if (_loc_2.itemCode == 0)
                {
                    _loc_3 = new ItemData(_loc_2.unit);
                }
                else
                {
                    _loc_3 = new ItemData(_loc_2.itemCode);
                }
                _loc_3.itemAmount = _loc_2.amount;
                this._item.itemData = _loc_3;
                this._item.amount = _loc_2.amount;
            }
            return;
        }// end function

    }
}
